<?php

class EntityController extends Jwawa_BaseController
{
    public function findEntityHeaderListAction(){
        $param = $this->getJsonDataFromReq();

        $sbr = new Jwawa_Db_SearchBuilder($param['searchPageCode'],
                                          $param['searchItems'],
                                          $param['start'],
                                          $param['limit']);
        $total = Model_Cfg_EntityHeader::countEntityHeaderListBySbr($sbr);
        $pageList = Model_Cfg_EntityHeader::findEntityHeaderListBySbr($sbr);

        $rst = new Jwawa_ResponseBaseDto($pageList, true, $total);
        $json = Zend_Json::encode($rst);
        echo $json;
    }
    public function findEntityDetailByEntityCodesAction(){
        $param = $this->getJsonDataFromReq();
        $entityMap = Model_Cfg_EntityDetail::findEntityDetailByEntityCodes($param);

        $rst = new Jwawa_ResponseBaseDto($entityMap);
        $json = Zend_Json::encode($rst);
        echo $json;
    }

    public function findAllEntitiesAction(){
        $entityList = Model_Cfg_EntityHeader::findAllEntities();

        $rst = new Jwawa_ResponseBaseDto($entityList);
        $json = Zend_Json::encode($rst);
        echo $json;
    }

    public function findEntityDetailListByHeaderIdAction(){
        $entityHeaderId= $this->getJsonDataFromReq();
        $entityDetailList = Model_Cfg_EntityDetail::findEntityDetailListByHeaderId($entityHeaderId);

        $rst = new Jwawa_ResponseBaseDto($entityDetailList);
        $json = Zend_Json::encode($rst);
        echo $json;
    }
}
